/**
 * <p>Copyright (c) 2011 深圳市鹏途信息技术有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	东莞交通工程质量监督综合业务系统        </p>
 * <p>创建者   :	Administrator 
 * 
 * <p>描   述  :   DetectionAction.java for com.pengtu.web.project    </p>
 * 
 * <p>最后修改 : $: 2011-8-25-下午02:06:02 v 1.0.0	 Administrator   $     </p>
 * 
*/

package com.pengtu.web.project;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.pengtu.dao.Page;
import com.pengtu.dao.QueryFilter;
import com.pengtu.entity.project.labs.Detectcontract;
import com.pengtu.service.project.labs.DetectcontractManager;
import com.pengtu.utils.web.Struts2Utils;
import com.pengtu.web.BaseActionSupport;

/**
 * 
 * DetectionAction
 * 
 * 2011-8-25 下午02:06:02
 * 
 * @version 1.0.0
 * 
 */
@Result(location = "${ctx}/project/sign/detection.action?projectId=${projectId}&contractKind=${contractKind}", name = BaseActionSupport.RELOAD, type = "redirect")
public class DetectionAction extends BaseActionSupport<Detectcontract>{

	/**
	 * serialVersionUID:TODO
	 *
	 * @since 1.0.0
	 */
	
	private static final long serialVersionUID = 1L;

	private String id;
	private Page<Detectcontract> page = new Page<Detectcontract>(10);
	private Detectcontract detectcontract;
	private DetectcontractManager detectcontractManager;
	private String projectId;
	private String typeId;
	private String deptId;
	
	@Action("/project/sign/detection")
	@Override
	public String list() throws Exception {
		QueryFilter queryfilter = QueryFilter.buildFromHttpRequest(Struts2Utils
				.getRequest());

		queryfilter.addFilter("projectId", projectId);
		if (!page.isOrderBySetted()) {
			page.orderBy("createDate");
			page.order(Page.ASC);
		}
		page = detectcontractManager.findPageDetect(page, queryfilter);
		return SUCCESS;
	}

	@Override
	public String input() throws Exception {
		System.out.println("******************"+projectId);
		return INPUT;
	}

	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String delete() throws Exception {
		detectcontractManager.deleteDetectcontract(id);
		return "successMessage";
	}

	@Override
	protected void prepareModel() throws Exception {
		if (StringUtils.isNotEmpty(id)) {
			detectcontract = detectcontractManager.getDetectcontract("id", id);
		} else {
			detectcontract = new Detectcontract();
		}		
	}
	
	@Override
	public Detectcontract getModel() {
		return detectcontract;
	}
	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}
	public String getDeptId() {
		return deptId;
	}

	@Autowired
	public void setDetectcontractManager(DetectcontractManager detectcontractManager) {
		this.detectcontractManager = detectcontractManager;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Page<Detectcontract> getPage() {
		return page;
	}

	public void setPage(Page<Detectcontract> page) {
		this.page = page;
	}

	public Detectcontract getDetectcontract() {
		return detectcontract;
	}

	public void setDetectcontract(Detectcontract detectcontract) {
		this.detectcontract = detectcontract;
	}

	public String getTypeId() {
		return typeId;
	}

	public void setTypeId(String typeId) {
		this.typeId = typeId;
	}

	public String getId() {
		return id;
	}

	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}
	
}
